package com.mbyte.easy.studenttask.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mbyte.easy.security.entity.SysUser;
import com.mbyte.easy.student.entity.Student;
import com.mbyte.easy.studenttask.entity.StudentTask;
import com.mbyte.easy.studenttask.mapper.StudentTaskMapper;
import com.mbyte.easy.studenttask.service.IStudentTaskService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mbyte.easy.task.entity.Task;
import com.mbyte.easy.task.service.ITaskService;
import com.mbyte.easy.util.Utility;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lp
 * @since 2020-06-18
 */
@Service
public class StudentTaskServiceImpl extends ServiceImpl<StudentTaskMapper, StudentTask> implements IStudentTaskService {

    @Autowired
    private IStudentTaskService taskService;
    @Override
    public IPage<StudentTask> page1(Page<StudentTask> userPage, QueryWrapper<StudentTask> queryWrapper) {
        IPage<StudentTask> page = page(userPage,queryWrapper);
        page.setRecords(null);
        SysUser sysUser = Utility.getCurrentUser();
        Long id = sysUser.getId();
        List<StudentTask> records = taskService.list(new LambdaQueryWrapper<StudentTask>().eq(StudentTask::getUserId,id));

        System.out.println(records);
        //List<StudentTask> taskList = taskService.list(new LambdaQueryWrapper<StudentTask>().eq(StudentTask::getUserId,id));

        page.setRecords(records);
        return page;
    }
}
